<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html>
 <head>
    <title>生产派工取消管理</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>
	<script src="${ctx}/js/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/logic/prodetail";
		var basic_WUrl="logic/prodetail";
		var basic_Title="生产派工取消";
		var show_Width=380;
		var show_Hight=400;
		function createSearch(){
			init(1,8,'100,100,100,100,100,100,100,100','10%');
			//第一行的数据
			addCommon(0,0,"lable","料单号：");
			addCommon(0,1,"txtlike","zd001FormCode");
			addCommon(0,2,"lable","PI编号：");
			addCommon(0,3,"txtlike","zd003PiCode");
			addCommon(0,4,"lable","生产派工号：");
			addCommon(0,5,"txtlike","zd002OriCode");
			addCommon(0,6,"lable","是否生成日报：");
			addCommon(0,7,"selectEnum","zd008WorkStatus","<option value='PRODISPATDTL_NO'>否</option><option value='PRODISPATDTL_YES'>是</option>");
			
		}
		
		function searchAP(type){
			multipleSearch("#table1",true,"",basic_Url+"/list.do");
		}
		document.onkeydown=keyListener;   
		function keyListener(e){   
		    e = e ? e : event;  
		    if(e.keyCode == 13){   
		    	searchAP();
		    }   
		}  
		//页面加载
		$(function(){
			$("#table1").ligerGrid({
		        columns: [
		                  { dispaly: 'id', name: 'id', hide:true},
		                  { display: '料单号', name: 'zd001FormCode', width: 180 },
		                  { display: '生产派工号', name: 'zd002OriCode', width: 180 },
		 				  { display: 'PI编号', name: 'zd003PiCode', width: 160 },
				          { display: '客户名称', name: 'zd004CustomerName', width: 180},
				          { display: '日报状态', name: 'zd008WorkStatus', width: 180,
		                	  render: function (item){               		 
		                		  var billStatus=item.zd008WorkStatus;
		                		  if(billStatus=="PRODISPATDTL_NO"){
		                			  return "<span style='color:red;'>未生成</span>";
		                		  } else if(billStatus=="PRODISPATDTL_YES"){
		                			  return "<span style='color:red;'>已生成</span>";
		                		  }else{
		                			  return "<span style='color:red;'>未生成</span>";
		                		  }
		                	  }
		                  },
		                  { display: '日报日期', name: 'zd008WorkDate', width: 180,
		                	  render: function (item){               		 
		                		  var dailyDate=item.zd008WorkDate;
		                		  if(dailyDate==null||dailyDate==''||dailyDate==undefined){
		                			  return "";
		                		  }else{
		                			  var ddate=new Date(dailyDate);
			                		  return formatDate(ddate,"yyyy-MM-dd");
		                		  }
		                	  }
		                  },
		                  { display: '创建时间', name: 'bizCreatorDate', width: 120,
		                	  render: function (item){
		                		  var cdate=new Date(item.bizCreatorDate);
		                		  return formatDate(cdate,"yyyy-MM-dd");
		                	  }}
		                 ],  
		                      usePager: true,pageSize:15,pageSizeOptions :[10,20,30,40,50], 
		                      enabledSort:false,
		                      url : basic_Url+"/list.do?",
		                      width: "100%", height:"98%", checkbox: true, rownumbers:true,     
		                      onDblClickRow : function (data, rowindex, rowobj){
		                    	  edit(data);
		                      }
		     });
			$("#pageloading").hide();
		});
		
		/*
		 * 删除订单
		 */
		function checkdel(){
			var manager = $("#table1").ligerGetGridManager(); 
			var rows = manager.getSelectedRows();
			if (rows==null || 0== rows.length){
				$.dialog.alert('请选择需要操作删除的行！');
				return;
			}
			var canDel = true;
			$(rows).each(function() {
				if (!(this.zd008Billstatus=="PRODISPAT_SAVE" )){
					canDel = false;
					$.dialog.alert('您删除的单据中,存在不能删除操作的单据状态！');
				}
				
				if(this.bizCreatorName !='${user.name}'){
					canDel = false;
					$.dialog.alert('您删除的单据中,存在非本人的单据，不能删除操作!');
				}
			});
			
			if(canDel){
				del();//ajax 删除
			}
		}
		//派工
		function dispatchTo(){
			var manager = $("#table1").ligerGetGridManager(); 
			var cRows = manager.getSelectedRows();
			if (cRows==null || 0== cRows.length){
				$.dialog.alert('请选择需要派工的行！');
				return;
			}else{
				if(cRows.length>1){
					$.dialog.alert('每次只能单行派工！');
					return ;
				}
				var dipatchingId = cRows[0].id;
				var url = basic_WUrl+"/operate/edit/"+dipatchingId+".do";
				ShowIframeDialog("operate","派工",url,show_Width,show_Hight);
			}
		}
	</script>
	
  </head>
 <body style="padding:10px" onload="createSearch()">  
       <div id="layout1">
          <div class="panelBar">
	            <ul class="toolBar">
		           <li><a class="add" onclick="dispatchTo()"><span>派工</span></a></li>
				   <li><a class="delete" onclick="checkdel()"><span>删除</span></a></li>
               </ul>
          </div>
          <div id="pageHeader" class="pageHeader">
          <input type="hidden" id="type" name="type" value="${type}"/>
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div>
      <div id="table1">
      </div>
      <div class="clear"></div>
    </body>
</html>